package starComponent.experiments.expedependencies;

import java.awt.Color;

import starComponent.E_PossibleBranches;
import starComponent.elements.Ladder;
import starComponent.elements.StarBranchBiSlider;
import starComponent.elements.StarBranchSlider;
import starComponent.elements.StarComponent;

/**
 * @author Charles Perin
 * 21 avr. 2011
 * LIMSI - INRIA Rennes
 * charles.perin@free.fr
 */
public class Expe1Dependencies_Scenario2_Cond1 extends A_Expe1Dependencies{

	
	public Expe1Dependencies_Scenario2_Cond1(int groupNumber){
		super(groupNumber);
		
		star.getControler().setDependenciesRangeDisplayed(true);
		star.getControler().setDependenciesFocusDisplayed(false);
		star.getControler().setDependenciesLinkDisplayed(false);
		
		this.thumbToObserve = "Average Speed";
		
		initStartButton(E_Experiment.DEPENDENCIES_SCENARIO2_INTERVALLES, 150, Validator.VALIDATE_IF_BIGGER_THAN);
		listenThumbToObserve();
	}


	@Override
	protected void buildBranchList(StarComponent star){
		star.initStar();

		StarBranchSlider nbKm = new StarBranchSlider(
				star, 
				E_PossibleBranches.NB_KM, 
				Color.RED,
				new Ladder(E_PossibleBranches.NB_KM,
						true,
						true, 
						Color.RED, 
						Color.RED,
						false),
						Math.toRadians(340),
						true);
		nbKm.setThumbColors(new Color[]{Color.BLACK, Color.GRAY}, new Color[]{Color.RED, new Color(255,200,200)});
		nbKm.setValue(400);

		StarBranchSlider gazol = new StarBranchSlider(
				star, 
				E_PossibleBranches.GAZOL, 
				Color.BLUE,
				new Ladder(E_PossibleBranches.GAZOL,
						true,
						true, 
						Color.BLUE, 
						Color.BLUE,
						false),
						Math.toRadians(65),
						true);
		nbKm.setThumbColors(new Color[]{Color.BLACK, Color.GRAY}, new Color[]{Color.RED, new Color(255,200,200)});
		gazol.setValue(75);

		StarBranchSlider averageSpeed = new StarBranchSlider(
				star, 
				E_PossibleBranches.AVERAGE_SPEED, 
				Color.GREEN,
				new Ladder(E_PossibleBranches.AVERAGE_SPEED,
						true,
						true, 
						Color.GREEN, 
						Color.GREEN,
						false),
						Math.toRadians(180),
						true);
		nbKm.setThumbColors(new Color[]{Color.BLACK, Color.GRAY}, new Color[]{Color.RED, new Color(255,200,200)});
		averageSpeed.setValue(100);

		StarBranchSlider lawViolation = new StarBranchSlider(
				star, 
				E_PossibleBranches.LAW_VIOLATION_PROBABILITY, 
				Color.MAGENTA,
				new Ladder(E_PossibleBranches.LAW_VIOLATION_PROBABILITY,
						true, 
						true, 
						Color.MAGENTA, 
						Color.MAGENTA,
						false),
						Math.toRadians(290),
						true);
		lawViolation.setThumbColors(new Color[]{Color.BLACK, Color.GRAY}, new Color[]{Color.RED, new Color(255,200,200)});
		lawViolation.setValue(1);

		StarBranchBiSlider cost = new StarBranchBiSlider(
				star, 
				E_PossibleBranches.COST,
				Color.BLACK,
				new Ladder(E_PossibleBranches.COST, 
						true, 
						true,
						Color.BLACK,
						Color.BLACK,
						false),
						Math.toRadians(30),
						true);
		cost.setRangeColor(Color.BLUE);
		cost.setMinRange(30.0);
		cost.setRangeThickness(10);
		cost.setMinValue(167);
		cost.setMaxValue(250);
		
		StarBranchSlider numberOfStops = new StarBranchSlider(
				star, 
				E_PossibleBranches.NUMBER_OF_STOPS, 
				Color.ORANGE,
				new Ladder(E_PossibleBranches.NUMBER_OF_STOPS,
						true,
						true,
						Color.ORANGE,
						Color.ORANGE,
						false), 
						Math.toRadians(0), 
						true);
		numberOfStops.setValue(2);

		star.getControler().addBranch(nbKm);
		star.getControler().addBranch(gazol);
		star.getControler().addBranch(averageSpeed);
		star.getControler().addBranch(lawViolation);
		star.getControler().addBranch(cost);
		star.getControler().addBranch(numberOfStops);

		star.getControler().orderBranchesByAngle();
		star.getControler().createAllBranches();
		star.getControler().createDependencies();
		
		

		star.revalidate();
	}


}
